// 创建Buffer的三种方法

// 1. alloc
let buffer1 = Buffer.alloc(10);
// <Buffer 00 00 00 00 00 00 00 00 00 00>
console.log(buffer1);

// 2.allocUnsafe
let buffer2 = Buffer.allocUnsafe(10);
// <Buffer 00 00 00 00 00 00 00 00 00 00>
console.log(buffer2);

// 通过字符串创建 Buffer
let buffer3 = Buffer.from('hello');
// <Buffer 68 65 6c 6c 6f>  是 hello 每个字符在 unicode 中对应的数字所对应的二进制
console.log(buffer3);

// 通过数组创建 Buffer
let buffer4 = Buffer.from([105, 108, 111, 118, 101, 121, 111, 117]);
console.log(buffer4);